<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('资深总监营销奖励列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 120px;">代理商编号：</label>
                                <input type="text" name="agentNum"/>
                            </li>
                            <li>
                                <label style="width: 120px;">代理商名称：</label>
                                <input type="text" name="agentName"/>
                            </li>
                            <li>
                                <label style="width: 120px;">所属顶级代理名称：</label>
                                <input type="text" name="topAgentNum"/>
                            </li>
                            <li>
                                <label style="width: 120px;">所属顶级代理编号：</label>
                                <input type="text" name="topAgentName"/>
                            </li>
                            <li>
                                <label style="width: 120px;">上级代理编号：</label>
                                <input type="text" name="onAgentNum"/>
                            </li>
                            <li>
                                <label style="width: 120px;">上级代理名称：</label>
                                <input type="text" name="onAgentName"/>
                            </li>
                            <li class="select-time">
                                <label style="width: 120px;">创建日期：</label>
                                <input type="text" class="time-input"  placeholder="开始日期" name="startTwo"/>
                                <span>-</span>
                                <input type="text" class="time-input"  placeholder="结束日期" name="endTwo"/>
                            </li>
                            <li class="select-time">
                                <label style="width: 120px;">到期日期：</label>
                                <input type="text" class="time-input"  placeholder="开始日期" name="start"/>
                                <span>-</span>
                                <input type="text" class="time-input"  placeholder="结束日期" name="end"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="insertReward()" shiro:hasPermission="AgentMarketingReward:AgentMarketingReward:add">
                    <i class="fa fa-plus"></i> 新增奖励
                </a>
               <!-- <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="AgentMarketingReward:AgentMarketingReward:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="AgentMarketingReward:AgentMarketingReward:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="AgentMarketingReward:AgentMarketingReward:export">
                    <i class="fa fa-download"></i> 导出
                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" class="table text-nowrap"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('AgentMarketingReward:AgentMarketingReward:edit')}]];
        var removeFlag = [[${@permission.hasPermi('AgentMarketingReward:AgentMarketingReward:remove')}]];
        var prefix = ctx + "AgentMarketingReward/AgentMarketingReward";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "资深总监营销奖励",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'agentNum',
                    title: '服务商编号'
                },
                {
                    field: 'agentName',
                    title: '服务商名称'
                },
                {
                    field: 'topAgentNum',
                    title: '所属营销总监名称'
                },
                {
                    field: 'topAgentName',
                    title: '所属营销总监编号'
                },
                {
                    field: 'onAgentNum',
                    title: '上级服务商编号'
                },
                {
                    field: 'onAgentName',
                    title: '上级服务商名称'
                },
                {
                    field: 'addDate',
                    title: '添加时间'
                },
                {
                    field: 'endDate',
                    title: '到期时间'
                },
                {
                    field: 'fxEight',
                    title: '营销返现( 8元)'
                },
                {
                    field: 'fxFour',
                    title: '营销返现(4元)'
                },
                {
                    field: 'fxYsf',
                    title: '云闪付'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter:function(value,row,index){
                        return statusTools(row);
                    }
                },
                {
                    field: 'addMan',
                    title: '添加人'
                },

                /*{
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }*/]
            };
            $.table.init(options);
        });



        /* 营销奖励 */
        function statusTools(row) {
            if (row.status == 1) {
                return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\',\'' + row.agentNum + '\')"></i> ';
            } else {
                return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\',\'' + row.agentNum + '\')"></i> ';
            }
        }

        /* 营销奖励-停用 */
        function disable(id,agentNum) {
            $.modal.confirm("确认要禁用当前营销奖励吗？", function() {
                $.operate.post(prefix + "/edit", { "id": id, "status": 0, "agentNum": agentNum});
            })
        }

        /* 营销奖励-启用 */
        function enable(id,agentNum) {
            $.modal.confirm("确认要启用当前营销奖励吗？", function() {
                $.operate.post(prefix + "/edit", { "id": id, "status": 1, "agentNum": agentNum});
            })
        }

        /**
         * 新增奖励
         */
        function insertReward() {
            $.modal.open("新增奖励", prefix + "/rewardAdd","1300","750");
        }
    </script>
</body>
</html>